package com.simple.web.controller;

import com.alibaba.fastjson.JSON;
import com.simple.web.utils.SpringProducer;
import com.ychen.api.dto.ExchangeOrder;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author chenyuliao
 * @version 1.0
 * @description
 * @date 2021/1/19 23:26
 */
@Controller
@RequestMapping("order")
public class OrderController {

    @Autowired
    private SpringProducer springProducer;

    /**
     * 变量用途枚举
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("submitOrder")
    public Object submitOrder(@RequestBody ExchangeOrder exchangeOrder) {

        springProducer.sendMsg("ORDER_TOPIC", JSON.toJSONString(exchangeOrder));
//        rocketMQTemplate.convertAndSend("topic1", JSON.toJSONString(exchangeOrder));
        return null;
    }


}
